//
//  CGAccountAppealViewController.m
//  SchoolClient
//
//  Created by mac on 15/11/3.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "CGAccountAppealViewController.h"


@interface CGAccountAppealViewController ()<UITextFieldDelegate>

@property(nonatomic,strong)CGInputTextView *nameText;          //姓名
@property(nonatomic,strong)CGInputTextView *schoolText;        //学校
@property(nonatomic,strong)CGInputTextView *studentIdText;     //学号
@property(nonatomic,strong)CGInputTextView *qqText;            //QQ
@property(nonatomic,strong)CGInputTextView *idCardText;        //身份证
@property(nonatomic,strong)UIButton *nextButton;               //下一步

@end

@implementation CGAccountAppealViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"账号申诉";
    self.view.backgroundColor = [Tools getColor:@"ebebeb"];
    

    [self layoutUI];

}

-(void)layoutUI{
   
    //标提Lable
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, 20)];
    titleLabel.text = @"请尽量填写完整的个人信息,以帮助我们确认您的身份";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.adjustsFontSizeToFitWidth = YES;
    [self.view addSubview:titleLabel];
    //姓名View
    CGRect aFrame = CGRectMake(0, 40, SCREEN_WIDTH, 44);
    self.nameText = [[CGInputTextView alloc]initWithFrame:aFrame];
    self.nameText.label.text = @"姓名";
    self.nameText.textField.placeholder = @"请输入您的真实姓名";
    self.nameText.textField.delegate = self;
    [self.view addSubview:self.nameText];
    //大学View
    aFrame.origin.y += 45;
    self.schoolText = [[CGInputTextView alloc]initWithFrame:aFrame];
    self.schoolText.label.text = @"大学";
    self.schoolText.textField.placeholder = @"请输入您就读的大学名称";
    self.schoolText.textField.delegate  = self;
    [self.view addSubview:self.schoolText];
    //学号View
    aFrame.origin.y += 45;
    self.studentIdText = [[CGInputTextView alloc]initWithFrame:aFrame];
    self.studentIdText.label.text = @"学号";
    self.studentIdText.textField.placeholder = @"请输入您的学号";
    self.studentIdText.textField.delegate = self;
    [self.view addSubview:self.studentIdText];
    //QQ号View
    aFrame.origin.y += 45;
    self.qqText = [[CGInputTextView alloc]initWithFrame:aFrame];
    self.qqText.label.text = @"QQ";
    self.qqText.textField.placeholder = @"请输入您常用的QQ号";
    self.qqText.textField.delegate = self;
    [self.view addSubview:self.qqText];
    //身份证View
    aFrame.origin.y += 45;
    self.idCardText = [[CGInputTextView alloc]initWithFrame:aFrame];
    self.idCardText.label.text = @"身份证";
    self.idCardText.textField.placeholder = @"请输入您真实的身份证号";
    self.idCardText.textField.delegate = self;
    [self.view addSubview:self.idCardText];
    //下一步button
    aFrame.origin.y += 80;
    aFrame.origin.x = 20;
    aFrame.size.width = SCREEN_WIDTH - 40;
    self.nextButton = [[UIButton alloc]initWithFrame:aFrame];
    [self.nextButton setBackgroundImage:[UIImage imageNamed:@"login_btn_bg"] forState:UIControlStateNormal];
    [self.nextButton setTitle:@"下一步" forState:UIControlStateNormal];
    self.nextButton.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    [self.view addSubview:self.nextButton];
    //添加点击事件
    [self.nextButton addTarget:self action:@selector(tapNextButton:) forControlEvents:UIControlEventTouchUpInside];

    [self.studentIdText.textField addTarget:self action:@selector(moveView) forControlEvents:UIControlEventEditingDidBegin];
    [self.qqText.textField addTarget:self action:@selector(moveView) forControlEvents:UIControlEventEditingDidBegin];
    [self.idCardText.textField addTarget:self action:@selector(moveView) forControlEvents:UIControlEventEditingDidBegin];
    
}

#pragma mark 下一步点击事件
-(void)tapNextButton:(UIButton *)sender{
    
    NSLog(@"%s",__func__);
}


#pragma mark 键盘弹出/退回事件
-(void)moveView{
[UIView animateWithDuration:0.5 animations:^{
    self.view.frame = CGRectMake(0, -55, SCREEN_WIDTH, SCREEN_HEIGHT);
}];

}

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    [self.view endEditing:YES];
    if (textField == self.studentIdText.textField || textField == self.qqText.textField || textField == self.idCardText.textField) {
        [UIView animateWithDuration:0.5 animations:^{
            self.view.frame = CGRectMake(0, 60, SCREEN_WIDTH, SCREEN_HEIGHT);
        }];
    }
    return YES;
}

@end
